<?php

/**
 * This is the model class for table "tbl_subscription_type".
 *
 * The followings are the available columns in table 'tbl_subscription_type':
 * @property string $id
 * @property string $name
 * @property integer $enabled
 * @property integer $free
 * @property integer $vip
 * @property integer $contract
 * @property string $contract_no
 * @property integer $company
 * @property integer $billed_30days
 * @property integer $billed_monthly
 * @property integer $billed_manually
 * @property integer $invoice
 */
class SubscriptionType extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SubscriptionType the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_subscription_type';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('enabled, free, vip, contract, company, billed_30days, billed_monthly, billed_manually, invoice', 'numerical', 'integerOnly'=>true),
			array('name', 'length', 'max'=>30),
			array('contract_no', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, enabled, free, vip, contract, contract_no, company, billed_30days, billed_monthly, billed_manually, invoice', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'enabled' => 'Enabled',
			'free' => 'Free',
			'vip' => 'Vip',
			'contract' => 'Contract',
			'contract_no' => 'Contract No',
			'company' => 'Company',
			'billed_30days' => 'Billed 30days',
			'billed_monthly' => 'Billed Monthly',
			'billed_manually' => 'Billed Manually',
			'invoice' => 'Invoice',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('enabled',$this->enabled);
		$criteria->compare('free',$this->free);
		$criteria->compare('vip',$this->vip);
		$criteria->compare('contract',$this->contract);
		$criteria->compare('contract_no',$this->contract_no,true);
		$criteria->compare('company',$this->company);
		$criteria->compare('billed_30days',$this->billed_30days);
		$criteria->compare('billed_monthly',$this->billed_monthly);
		$criteria->compare('billed_manually',$this->billed_manually);
		$criteria->compare('invoice',$this->invoice);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}